Skip to content

Hybim 634 vertexai tool calls#275

Open
shuwpan wants to merge 9 commits intosignalfx:mainfrom
shuwpan:HYBIM-634_vertexai-tool-calls
Open

Hybim 634 vertexai tool calls#275
shuwpan wants to merge 9 commits intosignalfx:mainfrom
shuwpan:HYBIM-634_vertexai-tool-calls

Conversation

@shuwpan
Copy link
Copy Markdown
Contributor

@shuwpan shuwpan commented Apr 15, 2026

Stacked on #271 (HYBIM-623_replace_current_impl_with_LLMInvocation)

  • Map function_call parts to ToolCall and function_response to ToolCallResponse
  • Populate request_functions from tool definitions (always emitted, independent of content capture)
  • Add extract_tool_definitions utility for Vertex AI Tool objects
  • Vertex AI has no TOOL_CALLS finish reason; STOP is kept as-is (matches upstream)
  • Add tests for function call spans, tool events, and gen_ai.request.function.* attributes

https://shw-playground.signalfx.com/#/apm/traces/288c2aa13aa53d9fb23e838e0c27db63
https://shw-playground.signalfx.com/#/apm/traces/d35e404fbf45b4624e356d908a7a9195

Copy link
Copy Markdown
Contributor

@adityamehra adityamehra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shuwpan

  • please update pyproject.toml
  • version.py for the initial release
  • add the vertex ai to .ci-main.yml similar to this

shuwpan added 8 commits May 5, 2026 16:41
…nvocation

- Migrate from raw spans to TelemetryHandler lifecycle (start_llm/stop_llm/fail_llm)
- Build LLMInvocation with text and tool-response message parts
- Remove _StabilityMode branching, events.py, and completion_hook paths
- Remove experimental test files (merged into main test suite)
…lResponse

- Map function_call parts to ToolCall, function_response to ToolCallResponse
- Populate request_functions from tool definitions (always, independent of content capture)
- Add tests for function call spans, tool events, and request function attributes
…itions with env var

- Use invocation.tool_definitions instead of invocation.attributes[GEN_AI_TOOL_DEFINITIONS]
- Gate tool_definitions with should_capture_tool_definitions() (OTEL_INSTRUMENTATION_GENAI_CAPTURE_TOOL_DEFINITIONS)
- Use invocation.output_type instead of invocation.attributes[GEN_AI_OUTPUT_TYPE]
- Set request_choice_count and request_top_k on LLMInvocation
- Extract top_k from Vertex AI GenerationConfig
- Add tests for tool_definitions opt-in behavior
- P2: Move duplicate assert_handler_event helper to shared_test_utils.py
- P3: Add test for _map_finish_reason(None) null safety path
- P3: Replace silent pass with logging.exception in defensive catch blocks
@shuwpan shuwpan force-pushed the HYBIM-634_vertexai-tool-calls branch from 807a83a to 1714180 Compare May 6, 2026 00:03
CI installs pytest-recording (from langchain test deps) which conflicts
with the module-scoped vcr fixture from pytest-vcr. Adapt conftest.py:
- Add pytest-recording/pytest-vcr detection (matching langchain pattern)
- Create VCR instance directly in generate_content fixture
- Simplify vertexai_init to always use anonymous credentials in tests

Signed-off-by: shuwpan <shuwpan@cisco.com>
@shuwpan shuwpan requested a review from adityamehra May 6, 2026 00:44
Copy link
Copy Markdown
Contributor

@adityamehra adityamehra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shuwpan please also add an examples where vertex ai LLM call uses a tool call

)

if capture_content and params.tools:
if capture_content and params.tools and should_capture_tool_definitions():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the latest usage regarding capture_content from main. We have removed it from the instrumentation layer as per this

except Exception:
pass
logging.exception("Failed to record LLM error")
raise
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be raising exceptions from the instrumentation layer. Logging should be fine. Please see openai_v2 for reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants